import request from "@/utils/request";
import { setToken } from "@/utils/storage";
import { LOGIN ,LOGOUT} from "../constanst/login";
export const login = (payload) => {
  return async (dispatch) => {
    const res = await request({
      method:'post',
      url:"/authorizations",
      data:payload
    })
    setToken(res.data.data.token)
    dispatch({
      type:LOGIN,
      payload:res.data.data.token
    })
  }
}
/**
 * 退出并清除token
 * @param {*} payload 
 * @returns 
 */
export const logout = (payload) => {
  
  return  {
            type:LOGOUT,
          }
 
}